<include file="Common:layout" />
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>首页广告位</h3>
                <h5>客户端商城首页广告列表</h5>
            </div>
        </div>
    </div>

    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>广告列表</h3>
                <h5>(共{$total}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th align="center" abbr="article_title" axis="col3" class="">
                            <div style="text-align: center; width: 50px;" class="">ID</div>
                        </th>
                        <th align="center" abbr="article_title" axis="col3" class="">
                            <div style="text-align: center; width: 100px;" class="">广告位名称</div>
                        </th>
                        <th align="center" abbr="ac_id" axis="col4" class="">
                            <div style="text-align: center; width: 90px;" class="">图片</div>
                        </th>
                        <th align="center" abbr="ac_id" axis="col4" class="">
                            <div style="text-align: center; width: 80px;" class="">位置</div>
                        </th>
                        <th align="center" abbr="article_show" axis="col5" class="">
                            <div style="text-align: center; width: 200px;" class="">广告链接</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width: 60px;" class="">是否启用</div>
                        </th>
                        <th align="center" abbr="article_time" axis="col6" class="">
                            <div style="text-align: center; width:50px;" class="">权重</div>
                        </th>
                        <th align="center" axis="col1" class="handle">
                            <div style="text-align: center; width: 90px;">操作</div>
                        </th>
                        <th style="width:100%" axis="col7">
                            <div></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton"> <a href="{:U('Index/ad_set')}">
                    <div class="add" title="新增品牌">
                        <span><i class="fa fa-plus"></i>新增广告位</span>
                    </div>
                </a>
                </div>
            </div>
            <div style="clear:both"></div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table>
                    <tbody>
                    <volist name="ads" id="ad">
                        <tr>
                            <td align="left" class="">
                                <div style="text-align: left; width: 50px;">{$ad.ad_id}</div>
                            </td>
                            <td align="left" class="">
                                <div style="text-align: left; width: 100px;">{$ad.ad_name}</div>
                            </td>
                            <td align="left" class="">
                                <div style="text-align: left; width: 90px;">
                                    <a href="{$ad.ad_pic}" target="_blank"><img onMouseOver="$(this).attr('width','80').attr('height','45');" onMouseOut="$(this).attr('width','40').attr('height','30');" width="40" height="30" src="{$ad.ad_pic}"/></a>
                                </div>
                            </td>
                            <td align="left" class="">
                                <div style="text-align: left; width: 80px;">
                                    {$ad.ad_position}
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 200px;">{$ad[ad_link]}</div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 60px;">
                                    <if condition='$ad[ad_status] eq 1'>
                                        <span class="yes" onClick="changeTableVal('index_ad','ad_id','{$ad.ad_id}','ad_status',this)" ><i class="fa fa-check-circle"></i>是</span>
                                        <else/>
                                        <span class="no" onClick="changeTableVal('index_ad','ad_id','{$ad.ad_id}','ad_status',this)" ><i class="fa fa-ban"></i>否</span>
                                    </if>
                                </div>
                            </td>
                            <td align="center">
                                <div style="text-align: center; width:50px;">
                                    <input type="text" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onblur="changeTableVal('index_ad','ad_id','{$ad.ad_id}','ad_weight',this)" size="4" value="{$ad.ad_weight}" />
                                </div>
                            </td>
                            <td align="center" class="handle">
                                <div style="text-align: center; width: 90px;">
                                    <a href="{:U('Index/ad_edit',array('id'=>$ad['ad_id']))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>编辑</a>
                                    <a class="btn red"  href="javascript:void(0)"  onclick="del({$ad[ad_id]})"><i class="fa fa-trash-o"></i>删除</a>
                                </div>
                            </td>
                            <td align="" class="" style="width: 100%;">
                                <div>&nbsp;</div>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
            <!--分页位置-->
            {$page}
        </div>
    </div>
</div>
</div>
<script>
    // 删除操作
    function del(id)
    {
        layer.confirm('确认删除，此操作不可恢复？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    // 确定
                    $.ajax({
                        url: "{:U('Index/ad_del')}",
                        type:"GET",
                        data:{ad_id :id} ,
                        dataType :"json",
                        success: function (v) {
                            if (v.status == "success")
                                location.reload(true);
                            else
                                layer.msg(v.msg, {icon: 2, time: 1500});
                        }
                    });
                }, function (index) {
                    layer.close(index);
                }
        );
    }

    $(document).ready(function(){
        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });
</script>
</body>
</html>